/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ejb.negocio;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.ejb.persistencia.Administrador;

/**
 *
 * @author MoisesAntonio
 */
@Stateless
public class AdministradorFacade extends AbstractFacade<Administrador> {
    @PersistenceContext(unitName = "PruebaBBDD10PU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public AdministradorFacade() {
        super(Administrador.class);
    }
    
    public Administrador login(String id, String pass){
        List<Administrador> admin=em.createQuery("SELECT c FROM Administrador c WHERE c.nombreAdmin=:id AND c.pass=:pass").setParameter("id", id).setParameter("pass", pass).getResultList();
        if(admin.size()==1){
            return admin.get(0);
        }
        return null;
    }
}
